const Koa = require('koa')
const app = new Koa()
const cors = require('koa2-cors');
const router = require('koa-router')();
const msbd = require("./routes/msbd")
const users = require("./routes/users")
var bodyParser = require('koa-bodyparser');
app.use(cors());
app.use(bodyParser());
app.use(router.routes())
app.use(msbd.routes())
app.use(users.routes())

// koa2 - cors 解决跨域问题





app.use(async (ctx) => {
    // ctx.body = 'hello koa2'
})

router.get("/", ctx => {
    ctx.body = "router 路由配置"
    // console.log(ctx.query);
})

router.post("/addList", ctx => {
    // ctx.body = "新增"
    ctx.body = ctx.request.body
})


app.listen(3000)
console.log('[demo] start-quick is starting at port 3000')